package com.ttg.utils.connection.handler;

//~--- non-JDK imports --------------------------------------------------------

import com.ttg.utils.Assert;

import java.io.File;
import java.io.UnsupportedEncodingException;
import java.nio.charset.Charset;

//~--- JDK imports ------------------------------------------------------------

//~--- classes ----------------------------------------------------------------

/**
 * Class ParamsAndFileHttpResponse
 * Description
 * Create 2016-02-25 01:04:16 
 * @author Ardy    
 */
public class ParamsAndFileHttpResponse extends BaseHttpResponse {

    /** 
     * Field serialVersionUID
     * Description 
     */
    private static final long serialVersionUID = -7870994308137231081L;

    /** 
     * Field byteResult
     * Description 
     */
    private byte[] byteResult;

    /** 
     * Field downlaodFile
     * Description 
     */
    private File downlaodFile;

    /**
     * Constructs ParamsAndFileHttpResponse
     * Description
     *
     * @param charset 类型：Charset
     */
    public ParamsAndFileHttpResponse(Charset charset) {
        super(charset);
    }

    /**
     * Method getByteResult 
     * Description 说明：
     *
     * @return 返回值说明：
     */
    public byte[] getByteResult() {
        return ( this.byteResult != null ) ? this.byteResult : null;
    }

    /**
     * Method setByteResult 
     * Description 说明：
     *
     * @param byteResult 说明：
     */
    void setByteResult(byte[] byteResult) {
        Assert.notNull(byteResult, "[Assertion failed] - this argument[byteResult] is required; it must not be null");
        this.byteResult = byteResult;
    }

    /**
     * Method getStringResult 
     * Description 说明：
     *
     * @return 返回值说明：
     *
     * @throws UnsupportedEncodingException 异常：
     */
    public String getStringResult() throws UnsupportedEncodingException {
        return ( this.byteResult != null ) ? new String(this.byteResult, this.getCharset().name()) : null;
    }

    /**
     * Method getDownlaodFile 
     * Description 说明：
     *
     * @return 返回值说明：
     */
    public File getDownlaodFile() {
        return this.downlaodFile;
    }

    /**
     * Method setDownlaodFile 
     * Description 说明：
     *
     * @param downlaodFile 说明：
     */
    public void setDownlaodFile(File downlaodFile) {
        Assert.notNull(downlaodFile,
                       "[Assertion failed] - this argument[downlaodFile] is required; it must not be null");
        this.downlaodFile = downlaodFile;
    }
}


//~ Formatted by Jindent --- http://www.jindent.com
